import sys
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QStackedLayout, QHBoxLayout, QWidget, QVBoxLayout
from layout_colorwidget import Color

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("My App")

        layout1 = QVBoxLayout()
        self.layout2 = QStackedLayout()
        layout3 = QHBoxLayout()

        self.layout2.addWidget(Color('red'))
        self.layout2.addWidget(Color('green'))
        self.layout2.addWidget(Color('blue'))
        layout1.addLayout(self.layout2)

        redButton = QPushButton('Red')
        greenButton = QPushButton('Green')
        blueButton = QPushButton('Blue')
        layout3.addWidget(redButton)
        layout3.addWidget(greenButton)
        layout3.addWidget(blueButton)
        layout1.addLayout(layout3)

        redButton.clicked.connect(self.red_button_clicked)
        greenButton.clicked.connect(self.green_button_clicked)
        blueButton.clicked.connect(self.blue_button_clicked)

        widget = QWidget()
        widget.setLayout(layout1)

        self.setCentralWidget(widget)

    def red_button_clicked(self):
        self.layout2.setCurrentIndex(0)

    def green_button_clicked(self):
        self.layout2.setCurrentIndex(1)

    def blue_button_clicked(self):
        self.layout2.setCurrentIndex(2)

app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()





        







